<?php


namespace app\adminapi\lists\user;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\member\MemberLevel;
use app\common\model\user\UserType;

/**
 * @projectName src
 */
class UserTypeLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
{

    /**
     * 设置搜索条件
     */
    public function setSearch(): array
    {
        return [
            '%like%'=>['type_name'],
            '='=>['id']
        ];
    }

    /**
     * 设置支持排序字段
     */
    public function setSortFields(): array
    {
        return ['create_time' => 'create_time', 'id' => 'id'];
    }

    /**
     * 设置默认排序
     */
    public function setDefaultOrder(): array
    {
        return ['id' => 'desc'];
    }

    /**
     * 获取列表
     * @return array
     */
    public function lists(): array
    {
        $userTypeLists = UserType::where($this->searchWhere)
            ->limit($this->limitOffset, $this->limitLength)
            ->order($this->sortOrder)
            ->select()
            ->toArray();
        return $userTypeLists;
    }

    /**
     * 获取数量
     */
    public function count(): int
    {
        return UserType::where($this->searchWhere)->count();
    }

    public function extend()
    {
        return [];
    }
}